import Vue from "vue";
import VueRouter from "vue-router";
import Home from "../views/Home.vue";

Vue.use(VueRouter);

const routes = [
  {
    path: "/",
    name: "Home",
    component: Home,
    redirect: "/users",
    children: [
      {
        path: "users",
        name: "Users",
        component: () =>
          import(/*webpackChunkName: 'Users'*/ "@/views/users/Index"),
      },
      {
        path: "roles",
        name: "Roles",
        component: () =>
          import(/*webpackChunkName: 'Rights'*/ "@/views/rights/Roles"),
      },
      {
        path: "rights",
        name: "Rights",
        component: () =>
          import(/*webpackChunkName: 'Rights'*/ "@/views/rights/Rights"),
      },
      {
        path: "goods",
        name: "Goods",
        component: () =>
          import(/*webpackChunkName: 'Goods'*/ "@/views/goods/Lists"),
      },
      {
        path: "goodsAdd",
        name: "GoodsAdd",
        component: () =>
          import(/*webpackChunkName: 'Goods'*/ "@/views/goods/Add"),
      },
      {
        path: "goodsEdit/:id",
        name: "GoodsEdit",
        component: () =>
          import(/*webpackChunkName: 'Goods'*/ "@/views/goods/Edit"),
      },
      {
        path: "params",
        name: "CatesParams",
        //路由懒加载，使用（）=>import异步加载组件，结合webpackChunkName 实现打包分模块
        component: () =>
          import(/*webpackChunkName: 'Goods'*/ "@/views/cates/Params"),
      },
      {
        path: "reports",
        name: "Report",
        //路由懒加载，使用（）=>import异步加载组件，结合webpackChunkName 实现打包分模块
        component: () =>
          import(/*webpackChunkName: 'Goods'*/ "@/views/report/Index"),
      },
    ],
  },
  {
    path: "/screen",
    name: "Screen",
    //路由懒加载，使用（）=>import异步加载组件，结合webpackChunkName 实现打包分模块
    component: () =>
      import(/*webpackChunkName: 'Goods'*/ "@/views/report/Chart"),
  },
  {
    path: "/login",
    name: "Login",
    component: () =>
      import(/*webpackChunkName: 'Login'*/ "@/views/login/Login"),
  },
  {
    path: "*",
    name: "404",
    component: () => import("@/views/404.vue"),
  },
];

const router = new VueRouter({
  mode: "history",
  base: process.env.VUE_APP_URL,
  routes,
});

export default router;
